package com.imooc.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class NameUtil {

    /**
     * 验证是否是Name
     * @param Name
     * @return
     */
    public static boolean verifyName(String Name){

        // Name验证规则
//        String regEx ="[A-Za-z]+://[A-Za-z0-9-_]+\\\\.[A-Za-z0-9-_%&\\?\\/.=]+";
        String regEx = "^[a-zA-Z0-9]{4,12}";
        // 编译正则表达式
        Pattern pattern = Pattern.compile(regEx);
        // 忽略大小写的写法
        // Pattern pat = Pattern.compile(regEx, Pattern.CASE_INSENSITIVE);
        Matcher matcher = pattern.matcher(Name);
        // 字符串是否与正则表达式相匹配
        boolean rs = matcher.matches();
        return rs;

    }

    public static void main(String[] args) {
        boolean res =
                verifyName("http://admin.imoocnews.com:9090/imooc-news/admin/friendLinks.html");
        System.out.println(res);
    }

}
